package com.zboin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zboin.common.domain.AjaxResult;
import com.zboin.domain.ArticleType;
import com.zboin.mapper.ArticleTypeMapper;
import org.springframework.stereotype.Service;

/**
 * @author zhboom
 * @date 2025/6/7 17:04
 */
@Service
public class ArticleTypeService {

    private final ArticleTypeMapper articleTypeMapper;

    public ArticleTypeService(ArticleTypeMapper articleTypeMapper) {
        this.articleTypeMapper = articleTypeMapper;
    }

    public void incrCount(String type, String username) {
        articleTypeMapper.incrCount(type, username);
    }

    public AjaxResult getAllType() {
        return AjaxResult.success(articleTypeMapper.selectList(new QueryWrapper<>()));
    }

    public AjaxResult addArticleType(ArticleType articleType) {
        return AjaxResult.toAjaxResult(articleTypeMapper.insert(articleType));
    }

    public ArticleType getTypeDetail(Integer typeId) {
        return articleTypeMapper.selectById(typeId);
    }
}
